/**
 * Handle changed data.
 *
 * @param {Number} oldValue old value
 * @param {Number} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"D6D66071-8F3B-4ACF-BBC0-D29A4957D6C9"}
 */
function onDataChange_pais(oldValue, newValue, event) {
	globals.gpais = pais_id;
	return true
}

/**
 * Handle changed data.
 *
 * @param {Number} oldValue old value
 * @param {Number} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"805A33BD-3D75-479F-8745-DFA7353C357E"}
 */
function onDataChange_provincia(oldValue, newValue, event) {
	globals.gregion = provincia_id;
	return true
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"882526DE-0FCA-4F1F-82AC-544D90C45890"}
 */
function onShow(firstShow, event) {
	globals.gpais = pais_id;
	globals.gregion = provincia_id;

}

/**
 * Callback method when form is (re)loaded.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"F17BB209-10DB-427B-8957-3F50CE6DEFD5"}
 */
function onLoad(event) {
	globals.gpais = pais_id;
	globals.gregion = provincia_id;
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"381686EC-9FA9-4E99-91E4-3638F29E4BD8"}
 */
function agregar(event) 
{
	var $form = elements.tabs_2.getTabFormNameAt(elements.tabs_2.tabIndex);
	var $rel = elements.tabs_2.getTabRelationNameAt(elements.tabs_2.tabIndex)
	forms.pacientes_det[$rel].newRecord()
	globals.formEnVentana($form+'_carga',$form+'_carga','Nuevo')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"65EC7CE3-7DDF-4273-BC36-949CC77A8D13"}
 */
function eliminar(event) {
	var cual_relacion = elements.tabs_2.getTabRelationNameAt(elements.tabs_2.tabIndex);
	if (cual_relacion != null)
	{
		forms.pacientes_det[cual_relacion].deleteRecord()
	}
}


/**
 * @properties={typeid:24,uuid:"143774A7-6656-43B2-9A6E-DBA88877A649"}
 */
function baja() {
	if (pacientes_to_paciente_diagnostico.getSize() > 0)
	{
		globals.DIALOGS.showWarningDialog('Aviso',"No puede eliminar este paciente porque tiene datos clínicos",'OK')
	}
	else
	{
		if (pacientes_to_muestras.getSize() != 0)
		{
			globals.DIALOGS.showWarningDialog('Aviso','No puede eliminar este paciente ya que tiene muestras cargadas','OK')
			return false
		}
		controller.deleteRecord()
	}
	return true
}


